package com.geoway.adf.report.controller;

import com.geoway.adf.report.excel.workbook.WorkBook;
import com.geoway.adf.report.po.WorkBookPO;
import com.geoway.adf.report.service.WorkBookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: lzw
 * @Date: 2024/1/22 15:44
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping(value = "/workbook", produces = {"application/json;charset=UTF-8" })
public class WorkBookController {
    @Autowired
    private WorkBookService workBookService;

    @GetMapping("/findById")
    public WorkBookPO findById(String id){
        return workBookService.findById(id).orElse(new WorkBookPO());
    }

    /**
     * 不加@RequestBody会导致list对象无法映射
     * @param workBook
     * @return
     */
    @PostMapping("/save")
    public WorkBookPO save(@RequestBody WorkBook workBook){
        return workBookService.save(WorkBookPO.toWorkBookPO(workBook));
    }
}
